package com.xing.cglib.mytest.weave;

import org.objectweb.asm.tree.*;
import org.objectweb.asm.*;

import java.util.ArrayList;

public class SynchronizedClassNode extends ClassNode {
	
	public SynchronizedClassNode(int asmApiLevel) {
		super(asmApiLevel);
	}
	
	public SynchronizedClassNode() {
		super(327680);
	}
	
	public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
		AnnotationNode an = new SynchronizedAnnotationNode(desc);
		if (visible) {
			if (this.visibleAnnotations == null) {
				this.visibleAnnotations = new ArrayList(1);
			}
			this.visibleAnnotations.add(an);
		} else {
			if (this.invisibleAnnotations == null) {
				this.invisibleAnnotations = new ArrayList(1);
			}
			this.invisibleAnnotations.add(an);
		}
		return an;
	}
	
	
	public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
		TypeAnnotationNode an = new SynchronizedTypeAnnotationNode(typeRef, typePath, desc);
		if (visible) {
			if (this.visibleTypeAnnotations == null) {
				this.visibleTypeAnnotations = new ArrayList(1);
			}
			this.visibleTypeAnnotations.add(an);
		} else {
			if (this.invisibleTypeAnnotations == null) {
				this.invisibleTypeAnnotations = new ArrayList(1);
			}
			this.invisibleTypeAnnotations.add(an);
		}
		return an;
	}
	
	
	public void visitInnerClass(String name, String outerName, String innerName, int access) {
		InnerClassNode icn = new SynchronizedInnerClassNode(name, outerName, innerName, access);
		this.innerClasses.add(icn);
	}
	
	
	public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
		FieldNode fn = new SynchronizedFieldNode(access, name, desc, signature, value);
		this.fields.add(fn);
		return fn;
	}
	
	
	public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
		MethodNode mn = new SynchronizedMethodNode(access, name, desc, signature, exceptions);
		this.methods.add(mn);
		return mn;
	}
	
	
	public synchronized void accept(ClassVisitor cv) {
		super.accept(cv);
	}
}
